package com.atguigu.oss.controller;

import com.atguigu.oss.service.OssService;
import common.atguigu.commonutils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/eduoss/fileoss")
@CrossOrigin
@Api(description = "阿里云文件上传")
public class OssController {
    @Autowired
    private OssService ossService;

    @ApiOperation(value = "文件上传")
    @PostMapping
    private R uplodeOssFile(@ApiParam(name = "file", value = "文件", required = true)
                                        MultipartFile file){
        String url = ossService.uploadFileAvator(file);
        return R.ok().message("上传成功").data("url",url);
    }
}
